/*************************************************************************
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ************************************************************************/


/**
 * @file
 * Rtp.h
 *
 * @author
 * Ales Podskalsky (<a href="mailto:podskale@fel.cvut.cz">podskale@fel.cvut.cz</a>)
 *
 * @brief
 * Class provides connector to RTP library.
 */

#ifndef CRTP_H
#define CRTP_H

#include <string>
#include <vector>
#include <cstdlib>
#include <stdint.h>

extern "C" {
#include "ortp/rtpsession.h"
}

class CRtp
{
public:
  CRtp();
  ~CRtp();
  void Init(fd_set *fdsRead, fd_set *fdsWrite) { m_fdsRead = fdsRead; m_fdsWrite = fdsWrite; }
  void SetFd();

  bool Connect(std::string strDestIP, int iDestPort);
  void Disconnect();
  bool BindPort(int iPortBase);
  uint16_t GetPortBase() const;

  int SendPacket(const std::string &strContent, unsigned int timestamp);
  int SendPacket(const char *data, size_t size, unsigned int timestamp);
  bool ReadPacket(std::string &strContent, unsigned int timestamp);

  bool SetPayloadType(bool mark, unsigned char type, unsigned int inc = 0);
  bool SetSendPayloadType(unsigned char type);
  bool SetRecvPayloadType(unsigned char type);
private:
  RtpSession *m_sess;
  uint16_t m_iPortBase;
  int user_ts;

  fd_set *m_fdsRead;
  fd_set *m_fdsWrite;
  RtpProfile m_sprofile, m_rprofile;
};

#endif // CRTP_H

